package com.weibo.click;

import java.util.Timer;
import java.util.TimerTask;

/**
 * 模拟人的随机移动鼠标，浏览微博消息的行为，避免客户端的Robot侦测！
 * @author Administrator
 *
 */
public class mockHumanBehaviourTask  extends TimerTask {
	private Timer timer = null;
	
	public mockHumanBehaviourTask(Timer timer){
		this.timer=timer;
	}
	@Override
	public void run() {
		try {
			System.out.println("开始模拟鼠标移动，防止Javascript的自动侦测...");
			ControlUtils.mouseMoveMock(timer);
			
			
			System.out.println("开始执行新的计时器timer...任务，随机移动鼠标");
			Timer timer1 = new java.util.Timer(true);
			mockHumanBehaviourTask task=new mockHumanBehaviourTask(timer1);
			int rest=ControlUtils.genRandomSeconds(15,25)*1000;//计时器在15 - 25秒后开始运行！
			timer1.schedule(task,rest);
			System.out.println(rest/1000+"秒之后开始新的计时器timer...");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
